home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
qtawk
/
apptdis.exp
< prev
next >
Wrap
Text File
|
1990-07-25
|
4KB
|
143 lines
# QTAwk utility to set alarm clock for next appointment time
# appointments stored in file "appoint.fle" in format:
#
# mm/dd/yy hh:mm appointment comments/description/place
# or
# mm/dd/yyyy hh:mm appointment comments/description/place
#
# the file "appoint.fle" is read until an appointment if found for today
# for which the appointment hour is equal to the current hour and
# the appointment minute is greater than the current minute
# or
# the appointment hour is greater than the current hour
# An informative message is issued about the time set for the
# appointment, and the program to set the alarm is invoked.
# Any appointment comments are displayed
# Times are military times ( 0 <= hh < 24 )
#
BEGIN {
stderr = "stderr";
if ( ARGC > 1 ) {
fprintf(stderr,"Incorrect Invocation.\nUsage: QTAwk -ftclk.exp\n");
exit;
}
# the following date formats would be used for U.S. style dates
t0date = sdate(0); # todays date: mm/dd/yy
t1date = sdate(1); # todays date: mm/dd/yyyy
greg_jul = FALSE;
split(t1date,tdate,/\//);
today_jdn = jdn(tdate[3],tdate[1],tdate[2]);
# special date
special_date = "08/31/1996";
split(special_date,spldate,/\//);
spl_date_jdn = jdn(spldate[3],spldate[1],spldate[2]);
days_rem = spl_date_jdn - today_jdn;
spl_day = (spl_date_jdn + 1) % 7;
last_week = spl_day ? 1 : 0;
# use following to allow more variation in date format
today = /^{_w}*({t0date}|{t1date}){_w}/;
# the following date formats would be used for European style dates
# t2date = sdate(2); # todays date: dd/mm/yy
# t3date = sdate(3); # todays date: dd/mm/yyyy
# use following to allow more variation in date format
# today = /^{_w}*({t2date}|{t3date}){_w}/;
time_pattern = /^[0-9]?[0-9]:[0-9][0-9]?$/;
colon_s = /:/;
slash_s = /\//;
split(t0date,cdate,slash_s);
ARGV[ARGC++] = "c:\\appt" ∩ cdate[3] ∩ ".dat";
split(stime(2),now,colon_s);
hour = 1;
minute = 2;
appt_set = FALSE; # appointment set flag
notice_hr = 00; # set time for notices == 00:00
l1_hdr = ".======== " ∩ t1date ∩ " ========.";
l2_hdr = ".==================.";
spl_hdr = "*> " ∩ t1date ∩ " <> " ∩ special_date ∩ " <";
print l1_hdr;
print "Appointments: " ∩ t0date;
print " Time\tPurpose";
print ".---.\t.----------->";
lunch_time = "11:30"; # lunch
split(lunch_time,lunch,colon_s);
cob_time = "16:05"; # close of business
split(cob_time,cob,colon_s);
if ( now[hour] < lunch[hour] ||
(now[hour] == lunch[hour] && now[minute] < lunch[minute]) ) {
appt_list[lunch_time] = "Lunch Time";
}
if ( now[hour] < cob[hour] ||
(now[hour] == cob[hour] && now[minute] < cob[minute]) ) {
appt_list[cob_time] = "Closing Time";
}
}
# find only those lines with todays date to set appointments
# use following to allow more variation in date format
today { # find records for today
local atime, ai, apt_time;
if ( $2 ~~ time_pattern ) {
split($2,atime,colon_s);
if ( atime[hour] == notice_hr &&
atime[minute] == 0 ) {
$1 = $2 = "";
notice[n_cnt++] = strim($0,TRUE,FALSE);
appt_set = TRUE;
} else if ( atime[hour] > now[hour] ||
(atime[hour] == now[hour] && atime[minute] > now[minute]) ) {
appt_time = $2;
$1 = $2 = "";
appt_list[appt_time] = strim($0,TRUE,FALSE);
appt_set = TRUE;
}
}
next;
}
{
if ( appt_set ) exit;
}
END {
for ( appt_time in notice ) printf("NOTICE\t%s\n",notice[appt_time]);
for ( appt_time in appt_list ) printf("%s\t%s\n",appt_time,appt_list[appt_time]);
# print l1_hdr;
print spl_hdr;
remg = "\tRemaining";
print "*\tDays: " ∩ days_rem ∩ remg;
print "*\tWeeks: " ∩ ((days_rem - spl_day)/7 + last_week) ∩ remg;
print "*\tMonths: " ∩ days_rem/30 ∩ remg;
print spl_hdr;
}
# function to convert year/month/day into julian day number
function jdn(year,month,day) {
local yr;
local pfac = 0.6;
local ljdn;
yr = year + (month - 3.0) / 12.0;
ljdn = int(367.0 * yr + pfac) - (2 * int(yr)) + int(yr/4.0)
+ int(day) + 1721117;
if ( !greg_jul ) ljdn += -int(yr/100.0) + int(yr/400.0) + 2;
return ljdn;
}